package com.huanxing.cloud.pay.api.handler.impl;

import com.huanxing.cloud.common.core.entity.Result;
import com.huanxing.cloud.pay.api.handler.PayOrderHandler;
import com.huanxing.cloud.pay.common.dto.PayOrderDTO;
import lombok.extern.slf4j.Slf4j;

/**
 * 支付抽象类
 *
 * @author lijx
 * @since 2023/4/18 19:11
 */
@Slf4j
public abstract class AbstractPayOrderHandler implements PayOrderHandler {

	@Override
	public Result pay(PayOrderDTO payOrderDTO) {
		// 参数检查
		validateRequest(payOrderDTO);
		// 支付逻辑
		doPay(payOrderDTO);
		// 后置处理
		postPay(payOrderDTO);
		return Result.success();
	}

	public abstract Result doPay(PayOrderDTO payOrderDTO);

	private void validateRequest(PayOrderDTO payOrderDTO) {
		// 参数检查
	}

	private void postPay(PayOrderDTO payOrderDTO) {
		// 后置处理
	}

}
